﻿<UserControl x:Class="SoftSource.Timecard.Entry.Views.EntryEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:localControls="clr-namespace:SoftSource.Timecard.Entry.Controls"
             xmlns:converters="clr-namespace:SoftSource.Timecard.Entry.Converters"
             xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls">

    <UserControl.Resources>
        <converters:ProjectIDToCategorySummaryConverter x:Key="ProjectIDToCategorySummaryConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          MinWidth="300">
        <Grid x:Name="EntryStackPanel"
              KeyDown="EntryStackPanel_KeyDown"
              Grid.Column="0"
              VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <StackPanel Grid.Column="0"
                        VerticalAlignment="Center">
                <StackPanel Margin="4">
                    <TextBlock HorizontalAlignment="Left"
                               Text="Project:" />
                    <ListBox x:Name="ProjectListBox"
                             MaxHeight="250"
                             ItemsSource="{Binding Projects}"
                             SelectedItem="{Binding Entry.ProjectID, Converter={StaticResource ProjectIDConverter}, Mode=TwoWay}"
                             DisplayMemberPath="Name" />
                </StackPanel>
                <StackPanel Margin="4"
                            DataContext="{Binding Entry}">
                    <TextBlock HorizontalAlignment="Left"
                               Text="Category:" />
                    <ListBox x:Name="CategoryListBox"
                             MaxHeight="250"
                             ItemsSource="{Binding ProjectID, Converter={StaticResource ProjectIDToCategorySummaryConverter}}"
                             SelectedItem="{Binding CategoryID, Converter={StaticResource CategoryIDConverter}, Mode=TwoWay}"
                             DisplayMemberPath="Name" />
                </StackPanel>
            </StackPanel>
            <StackPanel Grid.Column="1"
                        VerticalAlignment="Top">
                <StackPanel Margin="4">
                    <TextBlock HorizontalAlignment="Left"
                               Text="Date:" />
                    <controls:DatePicker x:Name="EntryDatePicker"
                                         SelectedDate="{Binding Entry.EntryDate, Mode=TwoWay}" />
                </StackPanel>
                <StackPanel Margin="4">
                    <CheckBox x:Name="OvernightStayCheckBox"
                              Content="Overnight Stay"
                              IsChecked="{Binding Entry.OvernightStay, Mode=TwoWay}" />
                </StackPanel>
                <StackPanel Margin="4">
                    <TextBlock HorizontalAlignment="Left"
                               Text="Hours:" />
                    <TextBox x:Name="HoursTextBox"
                             TextWrapping="Wrap"
                             Text="{Binding Entry.Duration, Mode=TwoWay}" />
                </StackPanel>
                <StackPanel Margin="4">
                    <TextBlock HorizontalAlignment="Left"
                               Text="Description:" />
                    <TextBox x:Name="DescriptionTextBox"
                             VerticalScrollBarVisibility="Auto"
                             TextWrapping="Wrap"
                             MaxLength="255"
                             MaxWidth="500"
                             Text="{Binding Entry.Description, Mode=TwoWay}"
                             MaxHeight="200" />
                </StackPanel>
            </StackPanel>
            <Grid Margin="4"
                  Grid.Row="1"
                  Grid.ColumnSpan="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Button Content="Save"
                        Click="Save_Click"
                        Margin="4" />
                <Button Margin="4"
                        Content="Clear"
                        Click="Clear_Click"
                        Grid.Column="1" />
                <Button Margin="4"
                        Content="Cancel"
                        Click="Cancel_Click"
                        Grid.Column="2" />
            </Grid>
        </Grid>
    </Grid>
</UserControl>
